<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateReservationsTable extends Migration
{
    /**
     * Run the migrations.
     * 预约挂号 预约列表状态
     * @return void
     */
    public function up()
    {
        Schema::create('st_reservations', function (Blueprint $table) {

            $table->increments('id');
            $table->unsignedInteger('doctor_id');
            $table->unsignedInteger('patient_id')->index();
            $table->date('time')->comment('预约时间');
            $table->boolean('am')->comment('预约时间端是否是上午，否代表下午');
            $table->unsignedTinyInteger('start')->comment('预约开始时间');
            $table->unsignedTinyInteger('end')->comment('预约结束时间');
            $table->unsignedTinyInteger('room')->comment('诊室号');

            $table->string('purpose')->comment('预约内容，打算做什么');
            $table->string('remark')->comment('备注');

            $table->unsignedTinyInteger('status')->default(1)->comment(
                '预约状态，0.预约请求未发送，1.预约请求已发送'
            );

            $table->softDeletes();
            $table->timestamps();

            $table->index(['doctor_id', 'patient_id']);
        }
        );
    }

    /**
     * Reverse the migrations.
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('appoints');
    }
}
